import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:xinxuan/common/button_util.dart';
import 'package:xinxuan/common/dialogs/del_dialog.dart';
import 'package:xinxuan/utils/color_util.dart';
import 'package:get/get.dart';

class StoreOrderBtns extends StatelessWidget {

  final int status;
  final Function toPayFun;
  final Function cleanOrderFun;
  final Function receiveOrderFun;


  StoreOrderBtns({
    required this.status, 
    required this.toPayFun, 
    required this.cleanOrderFun, 
    required this.receiveOrderFun
  });

  @override
  Widget build(BuildContext context) {
    List<Widget> widgets = [];
    if (status == 1) {
      widgets = [
        Container(
          width: 90.w,
          child: ButtonUtil(
            text: '取消订单', 
            fontSize: 14.sp, 
            borderRadius: 18.w, 
            height: 36.h, 
            textColor: textSubtitleColor,
            showBorder: true,
            borderColor: bgDisplayColor,
            bgColors: [
              bgWhiteColor,
              bgWhiteColor
            ],
            onTop: () {
              Get.dialog(DelDialog(message: '确认取消订单吗？', onTap: () {
                cleanOrderFun();
              }));
            }
          ),
        ),
        Container(
          width: 90.w,
          margin: EdgeInsets.only(left: 12.w),
          child: ButtonUtil(
            text: '去支付', 
            fontSize: 14.sp, 
            borderRadius: 18.w, 
            height: 36.h, 
            onTop: () {
              toPayFun();
            }
          ),
        )
      ];
    } else if (status == 5) {
      widgets = [
        Container(
          width: 90.w,
          margin: EdgeInsets.only(left: 8.w),
          child: ButtonUtil(
            text: '确认收货', 
            fontSize: 14.sp, 
            borderRadius: 18.w, 
            height: 36.h, 
            onTop: () {
              receiveOrderFun();
            }
          )
        )
      ];
    } else {
      return Container();
    }
    return Row(
      mainAxisAlignment: MainAxisAlignment.end,
      children: widgets,
    );
  }
}